package com.faxsun.admin.web.domain.util;

import com.faxsun.admin.web.domain.ExceptionResponseEntity;
import com.faxsun.admin.web.domain.ResponseEntity;
import com.faxsun.model.BaseParam;
import com.faxsun.model.response.Response;

/**
 * 工具类：将支付系统返回的response转换为用于界面显示的信息<br/>
 * 用法：<br/>
 * 在com.faxsun.admin.web.domain中创建用于显示的实体类，该实体类需继承自
 * {@link com.faxsun.admin.web.domain.ResponseEntity}，并实现Result自身的处理方法{@link ResponseEntity#buildFromResult}
 * 
 * @author zhaoteng.song@faxsun.com
 *
 */
public class ResponseConventor {

	public static final ExceptionResponseEntity EXCEPTION=new ExceptionResponseEntity();
	
	@SuppressWarnings("rawtypes")
	public static <T extends ResponseEntity> T buildFromResponse(
			Response response, Class<T> c) throws InstantiationException,
			IllegalAccessException {
		T t = c.newInstance();
		t.buildFromResponse(response);
		return t;
	}
}
